Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

Address.getStreet5   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
var GedcomX = require('../'),
2
    utils = require('../utils');
3
4
/**
5
 * An address.
6
 * 
7
 * @constructor
8
 * @param {Object} [json]
0 ignored issues
show
Documentation introduced by
The parameter [json] does not exist. Did you maybe forget to remove this comment?
Loading history...
9
 */
10
var Address = function(json){
11
  
12
  // Protect against forgetting the new keyword when calling the constructor
13
  if(!(this instanceof Address)){
14
    return new Address(json);
15
  }
16
  
17
  // If the given object is already an instance then just return it. DON'T copy it.
18
  if(Address.isInstance(json)){
19
    return json;
20
  }
21
  
22
  this.init(json);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
23
};
24
25
Address.prototype = Object.create(GedcomX.ExtensibleData.prototype);
26
27
Address._gedxClass = Address.prototype._gedxClass = 'GedcomX.Address';
28
29
Address.jsonProps = [
30
  'value',
31
  'city',
32
  'country',
33
  'postalCode',
34
  'stateOrProvince',
35
  'street',
36
  'street2',
37
  'street3',
38
  'street4',
39
  'street5',
40
  'street6'
41
];
42
43
/**
44
 * Check whether the given object is an instance of this class.
45
 * 
46
 * @param {Object} obj
47
 * @returns {Boolean}
48
 */
49
Address.isInstance = function(obj){
50
  return utils.isInstance(obj, this._gedxClass);
51
};
52
53
/**
54
 * Initialize from JSON
55
 * 
56
 * @param {Object}
0 ignored issues
show
Documentation introduced by
The parameter * does not exist. Did you maybe forget to remove this comment?
Loading history...
57
 * @return {Address} this
58
 */
59
Address.prototype.init = function(json){
60
  
61
  GedcomX.ExtensibleData.prototype.init.call(this, json);
62
  
63
  if(json){
64
    this.setValue(json.value);
65
    this.setCity(json.city);
66
    this.setCountry(json.country);
67
    this.setPostalCode(json.postalCode);
68
    this.setStateOrProvince(json.stateOrProvince);
69
    this.setStreet(json.street);
70
    this.setStreet2(json.street2);
71
    this.setStreet3(json.street3);
72
    this.setStreet4(json.street4);
73
    this.setStreet5(json.street5);
74
    this.setStreet6(json.street6);
75
  }
76
  return this;
77
};
78
79
/**
80
 * Get the complete address value
81
 * 
82
 * @returns {String}
83
 */
84
Address.prototype.getValue = function(){
85
  return this.value;
86
};
87
88
/**
89
 * Set the complete address value
90
 * 
91
 * @param {String} value
92
 * @return {Address}
93
 */
94
Address.prototype.setValue = function(value){
95
  this.value = value;
96
  return this;
97
};
98
99
/**
100
 * Get the city
101
 * 
102
 * @returns {String}
103
 */
104
Address.prototype.getCity = function(){
105
  return this.city;
106
};
107
108
/**
109
 * Set the city
110
 * 
111
 * @param {String} city
112
 * @returns {Address}
113
 */
114
Address.prototype.setCity = function(city){
115
  this.city = city;
116
  return this;
117
};
118
119
/**
120
 * Get the country
121
 * 
122
 * @returns {String}
123
 */
124
Address.prototype.getCountry = function(){
125
  return this.country;
126
};
127
128
/**
129
 * Set the country
130
 * 
131
 * @param {String} country
132
 * @returns {Address}
133
 */
134
Address.prototype.setCountry = function(country){
135
  this.country = country;
136
  return this;
137
};
138
139
/**
140
 * Get the postal code
141
 * 
142
 * @returns {String}
143
 */
144
Address.prototype.getPostalCode = function(){
145
  return this.postalCode;
146
};
147
148
/**
149
 * Set the postal code
150
 * 
151
 * @param {String} postalCode
152
 * @returns {Address}
153
 */
154
Address.prototype.setPostalCode = function(postalCode){
155
  this.postalCode = postalCode;
156
  return this;
157
};
158
159
/**
160
 * Get the state or province
161
 * 
162
 * @returns {String}
163
 */
164
Address.prototype.getStateOrProvince = function(){
165
  return this.stateOrProvince;
166
};
167
168
/**
169
 * Set the state or province
170
 * 
171
 * @param {String} stateOrProvince
172
 * @returns {Address}
173
 */
174
Address.prototype.setStateOrProvince = function(stateOrProvince){
175
  this.stateOrProvince = stateOrProvince;
176
  return this;
177
};
178
179
/**
180
 * Get the street
181
 * 
182
 * @returns {String}
183
 */
184
Address.prototype.getStreet = function(){
185
  return this.street;
186
};
187
188
/**
189
 * Set the street
190
 * 
191
 * @param {String} street
192
 * @returns {Address}
193
 */
194
Address.prototype.setStreet = function(street){
195
  this.street = street;
196
  return this;
197
};
198
199
/**
200
 * Get the street2
201
 * 
202
 * @returns {String}
203
 */
204
Address.prototype.getStreet2 = function(){
205
  return this.street2;
206
};
207
208
/**
209
 * Set the street2
210
 * 
211
 * @param {String} street2
212
 * @returns {Address}
213
 */
214
Address.prototype.setStreet2 = function(street2){
215
  this.street2 = street2;
216
  return this;
217
};
218
219
/**
220
 * Get the street3
221
 * 
222
 * @returns {String}
223
 */
224
Address.prototype.getStreet3 = function(){
225
  return this.street3;
226
};
227
228
/**
229
 * Set the street3
230
 * 
231
 * @param {String} street3
232
 * @returns {Address}
233
 */
234
Address.prototype.setStreet3 = function(street3){
235
  this.street3 = street3;
236
  return this;
237
};
238
239
/**
240
 * Get the street4
241
 * 
242
 * @returns {String}
243
 */
244
Address.prototype.getStreet4 = function(){
245
  return this.street4;
246
};
247
248
/**
249
 * Set the street4
250
 * 
251
 * @param {String} street4
252
 * @returns {Address}
253
 */
254
Address.prototype.setStreet4 = function(street4){
255
  this.street4 = street4;
256
  return this;
257
};
258
259
/**
260
 * Get the street5
261
 * 
262
 * @returns {String}
263
 */
264
Address.prototype.getStreet5 = function(){
265
  return this.street5;
266
};
267
268
/**
269
 * Set the street5
270
 * 
271
 * @param {String} street5
272
 * @returns {Address}
273
 */
274
Address.prototype.setStreet5 = function(street5){
275
  this.street5 = street5;
276
  return this;
277
};
278
279
/**
280
 * Get the street6
281
 * 
282
 * @returns {String}
283
 */
284
Address.prototype.getStreet6 = function(){
285
  return this.street6;
286
};
287
288
/**
289
 * Set the street6
290
 * 
291
 * @param {String} street6
292
 * @returns {Address}
293
 */
294
Address.prototype.setStreet6 = function(street6){
295
  this.street6 = street6;
296
  return this;
297
};
298
299
/**
300
 * Export the object as JSON
301
 * 
302
 * @return {Object} JSON object
303
 */
304
Address.prototype.toJSON = function(){
305
  return this._toJSON(GedcomX.ExtensibleData, Address.jsonProps);
306
};
307
308
module.exports = Address;